<?	
	/* Se asegura que el archivo es incluido por el index */
	defined( 'LOAD_MODULE_ACTION' ) or die( 'No esta permitido el acceso directo a ' . __FILE__ );  
		$this->oTmpObject = new Home_detalle_frm( $this );
	
	class Home_detalle_frm extends Frm
	{
	function setValue ( $ncDetalle, $ncHome, $ncCelda )
		{
			$cSql = "SELECT  ncDetalle, ncHome, ncCelda, cdDetalle,  cDescripcion,  cImagen,  cLink,  bActivo
				FROM gtHomeDetalle
				WHERE ncDetalle = '$ncDetalle' AND  ncHome = '$ncHome' AND  ncCelda = '$ncCelda' ";
			$aDatos = $this->oDatabase->getArray($cSql);	
			$this->setFieldsArray ( $aDatos );
		}
	function Home_detalle_frm( &$oModule )
		{
			$this->Frm( $oModule );
			//Crea los Objetos de los campos de edicion
			$this->aFields['ncDetalle']			= new InputNumber( "ncDetalle" );
			$this->aFields['ncHome']				= new InputList( "ncHome" );
			$this->aFields['ncCelda']				= new InputList( "ncCelda" );
			$this->aFields['cdDetalle']			= new InputText( "cdDetalle" );
			$this->aFields['cDescripcion']		= new InputText( "cDescripcion" );
			$this->aFields['cImagen']				= new InputPhoto( "cImagen", '', 159, 77, "files/home" );
			$this->aFields['cLink']					= new InputText( "cLink" );
			$this->aFields['bActivo']				= new InputList( "bActivo" );	
		}	
	function setLevel( $nLevel)
		{
			switch ( $nLevel )
			{
				case 1: 
					$this->aInput = array ('ncDetalle','ncHome','ncCelda', 'ncHome', 'ncCelda' );
					break;
				case 2: 
					$this->aInput = array ('ncDetalle','ncHome','ncCelda','cdDetalle','cDescripcion','cImagen','cLink','bActivo' );
					break;
			}
		}
	function initializeForm()
		{
			// Si viene el Ubicacion hace el retrieve
				if ( $this->isRetrievable() && $this->aFields['ncDetalle']->getValue() && $this->aFields['ncHome']->getValue() && $this->aFields['ncCelda']->getValue() )
				{
					$this->setValue( $this->aFields['ncDetalle']->getValue(), $this->aFields['ncHome']->getValue(), $this->aFields['ncCelda']->getValue() );
				}
			// Configura el Titulo
				$this->setLabel( "Home Detalle" );	
			return true;
		}
	function initializeField( $cField , &$oField )
		{			
			switch ( $cField )
			{
					case 'ncDetalle':
						$oField->setHidden();
					break;
					case 'ncHome':
						$oField->setLabel('Home');
						$cSql = "SELECT ncHome, cdHome FROM gtHome";
						$oField->setMatrix($this->oDatabase->getMatrix($cSql));
						$oField->setMandatory($this->isMandatory());
					break;
					case 'ncCelda':
						$oField->setLabel('Celda');
						$cSql = "SELECT ncCelda, cdCelda  FROM gtHomeCelda WHERE ncHome = " . $this->aFields['ncHome']->getValue();
						$oField->setMatrix($this->oDatabase->getMatrix($cSql));
						$oField->setMandatory($this->isMandatory());
					break;
					case 'cdDetalle':
						$oField->setLabel('Nombre');
						$oField->setMandatory($this->isMandatory());
					break;
					case 'cDescripcion':
						$oField->setLabel('Descripcion');
						$oField->setEditor();
					break;
					case 'cImagen':
						$oField->setLabel( 'Foto', 'F');
						$oField->setFormName( $this->getFormName());
					break;
					case 'cLink':
						$oField->setLabel('Link');
					break;
					case 'bActivo':
						$oField->setLabel('Activo');
						$oField->setBool();
					break;
			}
 		}
	}
?>